package com.lu.library.http

import com.google.gson.annotations.SerializedName
import com.lu.library.Constants

open class ApiResponse<T>(
    @SerializedName("code")open val code: Int? = 0,
    @SerializedName("msg")open val msg: String? = "",
    @SerializedName("data") val data: T?=null,
    var error:Throwable? = null
){
    val isSuccess: Boolean
        get() = code == Constants.API_SUCCESS
}
data class ApiSuccessResponse<T>(val response: T) : ApiResponse<T>(data = response)

class ApiEmptyResponse<T> : ApiResponse<T>()

data class ApiFailedResponse<T>(override val code: Int?, override val msg: String?) : ApiResponse<T>(code = code, msg = msg)

data class ApiErrorResponse<T>(val throwable: Throwable) : ApiResponse<T>(error = throwable)

